/*
 * Project: BoboDesignPattern
 * 
 * File Created at 2019年2月5日
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package test.lesson3;

/**
 * @Type MyQueue
 * @Desc
 * @author 52489
 * @date 2019年2月5日
 * @Version V1.0
 */
public class MyQueue {

    int a[] = {};

    public void add(int n) {
        int b[] = new int[a.length + 1];
        for (int i = 0; i < a.length; i++) {
            b[i] = a[i];
        }
        b[b.length - 1] = n;
        a = b;
    }

    public int poll() {
        int x = a[0];
        int b[] = new int[a.length - 1];

        for (int i = 0; i < a.length - 1; i++) {
            b[i] = a[i + 1];
        }

        a = b;
        return x;
    }

    public static void main(String[] args) {
        MyQueue myQueue = new MyQueue();
        myQueue.add(1);
        myQueue.add(2);
        myQueue.add(3);

        System.out.println(myQueue.poll());
        System.out.println(myQueue.poll());
        System.out.println(myQueue.poll());

    }

}
